const path = require("path");
const nodeExternals = require("webpack-node-externals");

module.exports = {
  entry: "./browser/index.js", //设置打包入口文件
  output: {
    filename: "index.js", //输出文件
    path: path.resolve(__dirname, "dist") //将boudle.js输出到当前目录的dist
  },
  mode: "development",
  module: {
    rules: [
      {
        test: /\.js?$/,
        loader: "babel-loader",
        exclude: /(node_modules)/,

        options: {
          presets: [
            "react", //编译react代码 jsx语法
            "stage-0",
            [
              "env",
              {
                targets: {
                  browsers: ["last 2 versions"] //浏览器最新的两个版本不做转义
                }
              }
            ]
          ],
          plugins: ["transform-class-properties", "transform-runtime"]
        }
      },
      {
        test: /\.css?$/,
        use: [
          "style-loader",
          {
            loader: "css-loader",
            options: {
              modules: true,
            
            }
          }
        ]
      }
    ]
  }
};
